<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('departments', function (Blueprint $table) {
            // 添加缺失的字段
            $table->integer('level')->default(1)->after('code')->comment('部门层级');
            $table->date('establishment_date')->nullable()->after('address')->comment('成立日期');
            $table->decimal('budget', 12, 2)->default(0)->after('establishment_date')->comment('预算金额');
            $table->decimal('current_budget', 12, 2)->default(0)->after('budget')->comment('当前预算');
            $table->text('notes')->nullable()->after('current_budget')->comment('备注信息');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('departments', function (Blueprint $table) {
            $table->dropColumn([
                'level',
                'establishment_date',
                'budget',
                'current_budget',
                'notes'
            ]);
        });
    }
};
